package dockyin.creative.pattern.singleton;

import java.util.Date;

public class Singleton {

    private static Singleton instance = null;

    private String id;

    private Singleton() {
        id = "si_" + (new Date()).getTime();
    }

    public void run() {
        System.out.println("Hello, I'm singleton " + id);
    }

    public static Singleton getInstance() {
        if (null == instance) {
            syncInit();
        }
        return instance;
    }

    private synchronized static void syncInit() {
        if (null == instance) {
            instance = new Singleton();
        }
    }
}
